% rpm=NMRGyroscope.ParametricMagnetometer.RubidiumParametricMagnetometer(session);
% nmr=NMRGyroscope.NMRSystem.XeNMRSystem(session);
% rpm.controller.setCurrentControlVoltX(7.97);
% rpm.GET_WorkingPoint;
gyro = NMRGyroscope.NMRGyroscope(session);
gyro.initialization();
%%
figure; ax=axes;
Nexp = 100; ratio = nan(1, Nexp); data=cell(1, Nexp);
for k = 1:Nexp
    [resonance, fidSignal, fidSpectrum]  = gyro.nmr.GET_FIDResonance;
    data{k} = struct('resonance', resonance,...
                     'fidSignal', fidSignal,...
                     'fidSpectrum', fidSpectrum,...
                     'freqRatio', gyro.nmr.getFrequencyRatio);
    session.addTemporaryData(data{k});
    
    ratio(k) = gyro.nmr.getFrequencyRatio();
    plot(ax, ratio, 'ro-');
end


session.addMeasurementData('freqRatio', data);
MeasurementSession.save(session.close());

freqRatio = zeros(1, Nexp);
for k=1:Nexp
    freqRatio(k) = data{k}.freqRatio;
end
figure
plot(freqRatio, '-ro', 'linewidth', 1.5);

%% Test two - sensitivity
startSession;
gyro = NMRGyroscope.NMRGyroscope(session);
gyro.initialization();
%%
gyro.nmr.GET_FIDResonance;
%%
gyro.getNMRSignal('window_time',130.0, 'total_duration', 120.0, 'PID1_P', -1e-3, 'PID1_I', -200e-6, 'PID2_P', -1e-3, 'PID1_I', -200e-6,'pidFilterBW1',14.09,'pidFilterBW2',4.697);
